package top.meeting.room.common.base;

import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

/**
 * 我有故事，你有酒么？
 * JKhaled created by yunqisong@foxmail.com 2017/7/22
 * FOR : 基本服务接口 - CRUD
 */
public interface IBaseService<Model, Query, Form> {
    /**
     * Model page
     *
     * @param query
     * @return
     */
    Page<Model> pageModel(Query query);

    /**
     * Record page
     *
     * @param query
     * @return
     */
    Page<Record> pageRecord(Query query);

    /**
     * Model entity
     *
     * @param id
     * @return
     */
    Model getModel(Long id);

    /**
     * Record entity
     *
     * @param id
     * @return
     */
    Record getRecord(Long id);

    /**
     * Save model by form
     *
     * @param form
     * @return
     */
    Model saveAsModel(Form form);

    /**
     * Save record by form
     *
     * @param form
     * @return
     */
    Record saveAsRecord(Form form);

    /**
     * Delete by id
     *
     * @param id
     * @return
     */
    void deleteById(Long id);

    /**
     * Delete by ids
     *
     * @param ids
     * @return
     */
    void deleteByIds(String ids);

    /**
     * Clear cache
     */
    void remove();
}
